Skip to content

feat: bundling cache expiration & bypass#497

Merged
harlan-zw merged 6 commits intomainfrom
issue-485-force-download-option
Sep 22, 2025
Merged

feat: bundling cache expiration & bypass#497
harlan-zw merged 6 commits intomainfrom
issue-485-force-download-option

Conversation

@harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Sep 18, 2025

🔗 Linked issue

#485

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

🚀 New Features

  • Bundle force option: Added bundle: 'force' which will always bypass the cache
  • Downloaded Script Cache expiration: Implemented cache expiration for downloaded scripts
  • Dynamic source warnings: Runtime warnings when attempting to bundle dynamic script sources

Bundle Usage Patterns

useScript

  // Standard bundling - caches 1 week
  useScript('https://example.com/script.js', { bundle: true })
  // Force download (never caches)
  useScript('https://example.com/script.js', { bundle: 'force' })

Registry Scripts

  useScriptGoogleAnalytics({
    id: 'GA_MEASUREMENT_ID',
    scriptOptions: {
      bundle: true // or 'force'
    }
  })

Add forceDownload option for development workflows where the latest version of scripts should always be downloaded, bypassing cache.

- Add forceDownload option to NuxtUseScriptOptions type with comprehensive documentation
- Update AssetBundlerTransformerOptions to include defaultForceDownload configuration
- Modify downloadScript function to skip cache when forceDownload is true
- Add logic to extract forceDownload option from script configuration
- Pass defaultForceDownload from module configuration to transformer
- Includes performance warnings about build time impact

Resolves #485

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
scripts-docs Ready Ready Preview Comment Sep 22, 2025 9:42am
scripts-playground Ready Ready Preview Comment Sep 22, 2025 9:42am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/scripts/@nuxt/scripts@497

commit: 9fc3555

@harlan-zw harlan-zw changed the title feat: add forceDownload option to bypass script cache feat: bundle: force Sep 22, 2025
@harlan-zw harlan-zw changed the title feat: bundle: force feat: script bundling improvements Sep 22, 2025
@harlan-zw harlan-zw marked this pull request as ready for review September 22, 2025 05:05
@harlan-zw harlan-zw changed the title feat: script bundling improvements feat: bundling cache expiration & bypass Sep 22, 2025
@harlan-zw harlan-zw merged commit bf491b5 into main Sep 22, 2025
9 checks passed
@harlan-zw harlan-zw deleted the issue-485-force-download-option branch September 22, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant